/*
 * @Description  : 
 * @Author       : zhao
 * @Date         : 2022-06-28 11:16:19
 * @LastEditors  : zhao
 * @LastEditTime : 2023-01-10 15:52:03
 */

let zpublic = {}


//深拷贝 -数组
zpublic.DeepCopyArr = function (data) {
  return data.map(e => { return { ...e } })
}

//预览 
zpublic.PreviewText = function (data) {
  let file = data.res
  // // 创建blob对象，解析流数据
  const blob = new Blob([data.res], {
    // 设置返回的文件类型
    // type: 'application/pdf;charset=UTF-8' 表示下载文档为pdf，如果是word则设置为msword，excel为excel
    // type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    type: data.type
  })
  let url = null
  if (window.createObjectURL !== undefined) { // basic
    url = window.createObjectURL(file)
  } else if (window.webkitURL !== undefined) { // webkit or chrome
    try {
      url = window.webkitURL.createObjectURL(file)
    } catch (error) {

    }
  } else if (window.URL !== undefined) { // mozilla(firefox)
    try {
      url = window.URL.createObjectURL(file)
    } catch (error) {

    }
  }

  return url

  // var r = window.open();
  // r.document.body.innerHTML = href;


}
export default zpublic

